import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { ExamsVO, ExamsForm, ExamsQuery } from '@/api/answer/exams/types';

/**
 * 查询考试/测验列表
 * @param query
 * @returns {*}
 */

export const listExams = (query?: ExamsQuery): AxiosPromise<ExamsVO[]> => {
  return request({
    url: '/answer/exams/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询考试/测验详细
 * @param examId
 */
export const getExams = (examId: string | number): AxiosPromise<ExamsVO> => {
  return request({
    url: '/answer/exams/' + examId,
    method: 'get'
  });
};

/**
 * 新增考试/测验
 * @param data
 */
export const addExams = (data: ExamsForm) => {
  return request({
    url: '/answer/exams',
    method: 'post',
    data: data
  });
};

/**
 * 修改考试/测验
 * @param data
 */
export const updateExams = (data: ExamsForm) => {
  return request({
    url: '/answer/exams',
    method: 'put',
    data: data
  });
};

/**
 * 删除考试/测验
 * @param examId
 */
export const delExams = (examId: string | number | Array<string | number>) => {
  return request({
    url: '/answer/exams/' + examId,
    method: 'delete'
  });
};
